import {mapGetters} from 'vuex'
import moment from 'moment';
import {ADPAGE,VIDEOURL,DYNAMIC,OCTIONTEXT,INDUSTRY,UPLOADVIDEO,IMGLIST,UPLOADCOVER,PROGRAM,ADDORIGIN} from '@/services/api'
import {ajaxrequest,ajaxfile,ajaxparems,ajaxnoparams} from '@/services/ajaxrequest'
var datainfo = [];
var medialabel =[
    {
        title: 'APP名称',
        dataIndex: 'name',
        filterMultiple: true,
    },
];

var scenelabel = [
    {
        title: '位置选择',
        dataIndex: 'name',
    },
];

var medialist = [
    {
        key:"1",
        name:"今日头条",
        value:"INVENTORY_FEED",
    },{
        key:"2",
        name:"西瓜视频",
        value:"INVENTORY_VIDEO_FEED",
    },{
        key:"3",
        name:"抖音火山版",
        value:"INVENTORY_HOTSOON_FEED",
    },{
        key:"4",
        name:"抖音",
        value:"INVENTORY_AWEME_FEED",
    },{
        key:"5",
        name:"穿山甲",
        value:"INVENTORY_UNION_SLOT",
    }
];

var scenelist = [
    {
        key:'1',
        name:'沉浸式竖版视频场景',
        value:'VIDEO_SCENE'
    },{
        key:'2',
        name:'信息流场景',
        value:'FEED_SCENE'
    },{
        key:'3',
        name:'视频后贴和尾帧场景',
        value:'TAIL_SCENE'
    }
];
var cenelistbox = [];
var mediaboxlist = [];

var dynamiclabel = [
    {
        title:'词包',
        dataIndex:"name",
    },
    {
        title:'默认词',
        dataIndex:'default_word',
    },
    {
        title:'替换词',
        dataIndex:'words',
        ellipsis: true,
    },{
        title:'用户覆盖率',
        dataIndex:'user_rate',
    },{
        title:'状态',
        dataIndex:'status',
        scopedSlots: { customRender: 'statusDemo' },
    },{
        title:'操作',
        name:'name',
        ids:'creative_word_id',
        scopedSlots: { customRender: 'action' }
    }
];
const landing_type = '';

var systemlabel = [
    {
        title:"系统推荐卖点",
        dataIndex:"name",
        
    }
];
var systemlist = [
    {
        key:'1',
        name:"真实模拟经营商战"
    },{
        key:'2',
        name:"建立属于自己的帝国"
    },{
        key:'3',
        name:"让你体验身临其境"
    },{
        key:'4',
        name:"带你打造商业帝国"
    },{
        key:'5',
        name:"让你的商业更加自信"
    },{
        key:'6',
        name:"开创自己的商业帝国"
    },{
        key:'7',
        name:"完全颠覆传统模式"
    },{
        key:'8',
        name:"我的命运由我掌握"
    },{
        key:'9',
        name:"白手起家逆袭成总裁"
    },{
        key:'10',
        name:"超炫酷的人物模型"
    }
];

var choicelabel = [
    {
        title:'ID',
        dataIndex: 'id',
    },{
        title:'创意包名称',
        dataIndex: 'name',
    },{
        title:'创建事件',
        dataIndex: 'name',
    },{
        title:'使用账号',
        dataIndex: 'name',
    },{
        title:'操作',
        dataIndex: 'option',
    },
];

var rowsystemlist = [];
export default {
    created(){
        // var ad_ids = this.$route.query.ad_id;
        var campaign_id = this.$route.query.campaign_id;
        this.id = this.$route.query.ad_id
        this.campaign_id = campaign_id;
        this.listNew();
    },
    beforeCreate() {
        this.form = this.$form.createForm(this);
    },
    data() {
        const paneslist = [
            {
                title:'竖版视频',
                img:this.imgurl('15_S.svg'),
                value:'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'140',
                    height:'250',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'横版视频',
                img:this.imgurl('5_S.svg'),
                value:'CREATIVE_IMAGE_MODE_VIDEO',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'250',
                    height:'140',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'大图横图',
                img:this.imgurl('3_S.svg'),
                value:'CREATIVE_IMAGE_MODE_LARGE',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'250',
                    height:'140',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'组图',
                img:this.imgurl('4_S.svg'),
                value:'CREATIVE_IMAGE_MODE_GROUP',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'178',
                    height:'117',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        group:[{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        },{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        },{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        }],
                        nametitle:'',
                        image_ids:[],
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:[],
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'小图',
                img:this.imgurl('2_S.svg'),
                value:'CREATIVE_IMAGE_MODE_SMALL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'232',
                    height:'152',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'大图竖图',
                img:this.imgurl('16_S.svg'),
                value:'CREATIVE_IMAGE_MODE_LARGE_VERTICAL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'140',
                    height:'250',
                    addpanel:[{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        derive_poster_cid:false,
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },
        ];
        const customlist = [
            {
                title:'竖版视频',
                img:this.imgurl('15_S.svg'),
                value:'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'140',
                    height:'250',
                    addpanel:[{
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        videoshow:false,
                        covershow:false,
                        image_id:'',
                        video_id:'',
                        videolist:[],
                        coverlist:[],
                        videoactive:'',
                        coveractive:'',
                        videonum:0,
                        covernum:0,
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'横版视频',
                img:this.imgurl('5_S.svg'),
                value:'CREATIVE_IMAGE_MODE_VIDEO',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'250',
                    height:'140',
                    addpanel:[{
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        videoshow:false,
                        covershow:false,
                        image_id:'',
                        video_id:'',
                        videolist:[],
                        coverlist:[],
                        videoactive:'',
                        coveractive:'',
                        videonum:0,
                        covernum:0,
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'大图横图',
                img:this.imgurl('3_S.svg'),
                value:'CREATIVE_IMAGE_MODE_LARGE',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'250',
                    height:'140',
                    addpanel:[{
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        videoshow:false,
                        covershow:false,
                        image_id:'',
                        video_id:'',
                        videolist:[],
                        coverlist:[],
                        videoactive:'',
                        coveractive:'',
                        videonum:0,
                        covernum:0,
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'小图',
                img:this.imgurl('2_S.svg'),
                value:'CREATIVE_IMAGE_MODE_SMALL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'232',
                    height:'152',
                    addpanel:[{
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        videoshow:false,
                        covershow:false,
                        image_id:'',
                        video_id:'',
                        videolist:[],
                        coverlist:[],
                        videoactive:'',
                        coveractive:'',
                        videonum:0,
                        covernum:0,
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },{
                title:'大图竖图',
                img:this.imgurl('16_S.svg'),
                value:'CREATIVE_IMAGE_MODE_LARGE_VERTICAL',
                content:{
                    panelshow:true,
                    show:false,
                    num:0,
                    width:'140',
                    height:'250',
                    addpanel:[{
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        videoshow:false,
                        covershow:false,
                        image_id:'',
                        video_id:'',
                        videolist:[],
                        coverlist:[],
                        videoactive:'',
                        coveractive:'',
                        videonum:0,
                        covernum:0,
                    }],
                    activeKey:1,
                    newTabIndex: 2,
                },
            },
        ];
        return {
            id:'',
            landing_type,
            campaign_id:'',
            datainfo,
            campaigninfo:[],
            advertiserinfo:[],
            inventory:"smart_inventory",
            material:"NONE",
            source:"0",
            title:'',
            num:[],
            pages:false,
            medialabel,
            medialist,
            scenelabel,
            scenelist,
            cenelistbox,
            mediaboxlist,
            originshow:true,
            modeacrive:"1",
            customactive:"1",
            progractive:'1',
            addlist:[1],
            originbtn:false,
            tablist:[1],
            tabactive:0,
            tabtrue:false,
            tabvideo:false,
            tabimage:false,
            videoshow:false,
            videodata:[],
            videoactive:'',
            videonum:0,
            creative_word_ids:[],
            dynamicmore:false,
            dynamiclabel,
            dynamiclist:[],
            cardbox:false,
            cardboximg:'',
            value:1,
            cardtitle:'',
            inputlist:[{
                valuename:'product_selling_points1',
                value:'',
            }],
            pointsnum:1,
            btnpoint:false,
            actiontext:'true',
            calllist:[],
            brandhome:0,
            avaterimg:'',
            comments:'0',
            toshow:'CREATIVE_DISPLAY_MODE_RANDOM',
            typelist:[],
            labellist:[],
            systemshow:false,
            systemlabel,
            systemlist,
            rowsystemlist,
            paneslist,
            customlist,
            videonums:[],
            imagenums:[],
            input:[{
                value:'title1',
                nametitle:'',
                dynamicmores:false,
                dynamiclists:[],
                words_ids:[],
            }],
            inputnum:1,
            addtitledis:false,
            choiceorignbox:false,
            choicelabel,
            logging: false,
        };
    },
    methods: {
        moment,
        async listNew(){
            var parems = {'id':this.id}
            // 获取计划详情
            await ajaxparems(ADPAGE,parems).then((res) => {
                var result=res.data;
                console.log(result);
                this.account_id = result.data.account_id;
                this.datainfo =result.data;
            })
            
            //获取行动号召
            var octionparems = {"text_type":'CALL_TO_ACTION'};
            ajaxrequest(this.account_id, OCTIONTEXT,octionparems).then((res) => {
                var octions=res.data;
                if(octions.code =="SUCCESS"){
                    this.calllist  = octions.data.list;
                }else{
                    this.$message.error(octions.message,3);
                }
                
            })
            
            
            //获取视频列表
            ajaxrequest(this.account_id, VIDEOURL,"").then((res) => {
                var videolist=res.data;
                if(videolist.code =="SUCCESS"){
                    this.videodata =videolist.data.list;
                }else{
                    this.$message.error(videolist.message,3);
                }
            })

            //获取广告组头像
            // ajaxrequest("1657869217074189", AVATAR,"").then((res) => {
            //     var avaterimg=res.data;
            //     console.log(avaterimg);
            // })

            //获取创意分类
            ajaxparems(INDUSTRY,"").then((res) => {
                var typeresult=res.data;
                if(typeresult.code == "SUCCESS"){
                    this.typelist = typeresult.data;
                }
            })
        },
        oninventory(e){
            //广告位置
            this.inventory = e.target.value;
        },
        onmaterial(e){
            //创意方式
            this.material = e.target.value;
        },
        onsource(e){
            //素材添加方式
            this.source = e.target.value;
        },
        addorigin(){
            //点击添加创意
            this.originshow = true;
        },
        addparogr(e){
            var u = e-1;
            if(u ==0 || u ==1){
                this.videonums.push(1);
            }else{
                this.imagesnums.push(1);
            }
    
            this.customlist[u].content.num +=1;
            this.customlist[u].content.panelshow = false,
            this.customlist[u].content.show = true;
        },
        originadd(){
            //程序化添加
            if(this.addlist.length ==9){
                this.originbtn = true;
            }else{
                this.originbtn = false;
            }
            this.addlist.push(this.addlist.length+1);
        },
        addpanel(e){
            // 点击添加创意盒子
            var u = e-1;
            this.paneslist[u].content.panelshow = false,
            this.paneslist[u].content.show = true;
            this.paneslist[u].content.num +=1;
            this.num.push(1);
        },
        onchange(e){
            console.log(e.target.value);
        },
        change(e){
            console.log(e);
            console.log(11);
        },
        onmodeacrive(e){
            //点击竖图类型
            this.modeacrive =e;
        },

        oncustom(e){
            //自定义创建
            this.customactive = e;
            var u = e-1;
            if(this.paneslist[u].content.panelshow == true){
                this.paneslist[u].content.panelshow = true;
                this.paneslist[u].content.show = false;
            }else{
                this.paneslist[u].content.panelshow = false;
                this.paneslist[u].content.show = true;
            }
        },
        oncustoms(e){
            // 程序化创建
            this.progractive = e;
            var u = e-1;
            if(this.customlist[u].content.panelshow == true){
                this.customlist[u].content.panelshow = true;
                this.customlist[u].content.show = false;
            }else{
                this.customlist[u].content.panelshow = false;
                this.customlist[u].content.show = true;
            }
        },
        callback(key) {
            console.log(key);
        },
        onEdit(targetKey, action) {
            // 删除标签页
            var sub = this.customactive-1;
            this[action](targetKey,sub);
        },
        add(u) {
            if(this.num.length >9){
                this.tabtrue = true;
                return;
            }else{
                this.tabtrue = false;
            }
            // const width = this
            const activeKey = `${this.paneslist[u].content.newTabIndex++}`;
            if(u ==3){
                this.paneslist[u].content.addpanel.push({
                    title:`创意${activeKey}`,
                    key:activeKey,
                    videoUrl:'',
                    group:[{
                        img:'',
                        showis:false,
                        nums:0,
                        activeimg:'',
                        image_id:'',
                    },{
                        img:'',
                        showis:false,
                        nums:0,
                        activeimg:'',
                        image_id:'',
                    },{
                        img:'',
                        showis:false,
                        nums:0,
                        activeimg:'',
                        image_id:'',
                    }],
                    nametitle:'',
                    image_ids:[],
                    video_id:'',
                    input:`title${activeKey}`,
                    videoshow:false,
                    covershow:false,
                    dynamicmore:false,
                    videonum:0,
                    covernum:[],
                    videolist:[],
                    coverlist:[],
                    dynamiclist:[],
                    videoactive:'',
                    coveractive:'',
                    creative_word_ids:[]
                });
            }else{
                this.paneslist[u].content.addpanel.push({
                    title:`创意${activeKey}`,
                    key:activeKey,
                    videoUrl:'',
                    imageUrl:'',
                    nametitle:'',
                    image_ids:[],
                    image_id:'',
                    video_id:'',
                    input:`title${activeKey}`,
                    videoshow:false,
                    covershow:false,
                    dynamicmore:false,
                    videonum:0,
                    covernum:0,
                    videolist:[],
                    coverlist:[],
                    dynamiclist:[],
                    videoactive:'',
                    coveractive:'',
                    creative_word_ids:[]
                });
            }
           
            this.paneslist[u].content.num+=1;
            this.num.push(1);
            this.paneslist[u].content.activeKey = activeKey;
        },
        addpush(u){
            // 程序化创意追加
            if(u ==0 || u ==1){
                if(this.videonums.length >9){
                    this.tabvideo = true;
                    return;
                }else{
                    this.tabvideo = false;
                }
                this.videonums.push(1);
            }else{
                if(this.imagenums.length >11){
                    this.tabimage = true;
                    return;
                }else{
                    this.tabimage = false;
                }
                this.imagenums.push(1);
            }
            const activeKey = `${this.customlist[u].content.newTabIndex++}`;
            this.customlist[u].content.addpanel.push({
                key:activeKey,
                videoUrl:'',
                imageUrl:'',
                videoshow:false,
                covershow:false,
                image_id:'',
                video_id:'',
                videolist:[],
                coverlist:[],
                videoactive:'',
                coveractive:'',
                videonum:0,
                covernum:0,
            });
            this.customlist[u].content.num+=1;
            this.customlist[u].content.activeKey = activeKey;
        },
        remove(targetKey,sub) {
            if(this.num.length <=10){
                this.tabtrue = false;
            }
            let activeKey = this.paneslist[sub].content.activeKey;
            let lastIndex;
            this.paneslist[sub].content.addpanel.forEach((pane, i) => {
              if (pane.key === targetKey) {
                lastIndex = i - 1;
              }
            });
            const panes = this.paneslist[sub].content.addpanel.filter(pane => pane.key !== targetKey);
            if (panes.length && activeKey === targetKey) {
              if (lastIndex >= 0) {
                activeKey = panes[lastIndex].key;
              } else {
                activeKey = panes[0].key;
              }
            }
            this.paneslist[sub].content.addpanel = panes;
            this.paneslist[sub].content.activeKey = activeKey;
            this.paneslist[sub].content.num =this.paneslist[sub].content.num -1;
            this.paneslist[sub].content.newTabIndex =this.paneslist[sub].content.newTabIndex -1;
            this.num.splice(-1, 1);
            if(this.paneslist[sub].content.addpanel.length ==0){
                this.paneslist[sub].content.panelshow =true;
                this.paneslist[sub].content.show =false;
                // this.customlist[sub].content.newTabIndex =2;
                this.paneslist[sub].content.newTabIndex =2;
                if(sub ==3){
                    this.paneslist[sub].content.addpanel = [{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        group:[{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        },{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        },{
                            img:'',
                            showis:false,
                            nums:0,
                            activeimg:'',
                            image_id:'',
                        }],
                        nametitle:'',
                        image_ids:[],
                        video_id:'',
                        input:'title1',
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:[],
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }];
                }else{
                    this.paneslist[sub].content.addpanel = [{
                        title:'创意1',
                        key:'1',
                        videoUrl:'',
                        imageUrl:'',
                        nametitle:'',
                        image_ids:[],
                        image_id:'',
                        video_id:'',
                        input:'title1',
                        videoshow:false,
                        covershow:false,
                        dynamicmore:false,
                        videonum:0,
                        covernum:0,
                        videolist:[],
                        coverlist:[],
                        dynamiclist:[],
                        videoactive:'',
                        coveractive:'',
                        creative_word_ids:[]
                    }];
                }
                
            }
        },
        removepush(targetKey,sub){
            // 程序化创意追减
            if(sub ==0 || sub ==1){
                if(this.videonums.length <=10){
                    this.tabvideo = false;
                }
            }else{
                if(this.imagenums.length <=12){
                    this.tabimage =false;
                }
            }
            let activeKey = this.customlist[sub].content.activeKey;
            let lastIndex;
            this.customlist[sub].content.addpanel.forEach((pane, i) => {
              if (pane.key == targetKey) {
                lastIndex = i - 1;
              }
            });
            const panes = this.customlist[sub].content.addpanel.filter(pane => pane.key !== targetKey);
            if (panes.length && activeKey === targetKey) {
              if (lastIndex >= 0) {
                activeKey = panes[lastIndex].key;
              } else {
                activeKey = panes[0].key;
              }
            }
            this.customlist[sub].content.addpanel = panes;
            this.customlist[sub].content.activeKey = activeKey;
            this.customlist[sub].content.num =this.customlist[sub].content.num -1;
            this.customlist[sub].content.newTabIndex =this.customlist[sub].content.newTabIndex -1;
            if(sub ==0 || sub==1){
                this.videonums.splice(-1, 1);
            }else{
                this.imagenums.splice(-1, 1);
            }
            if(this.customlist[sub].content.addpanel.length ==0){
                this.customlist[sub].content.panelshow =true;
                this.customlist[sub].content.show =false;
                this.customlist[sub].content.newTabIndex =2;
                this.customlist[sub].content.addpanel = [{key:1,
                    videoUrl:'',
                    imageUrl:'',
                    videoshow:false,
                    covershow:false,
                    image_id:'',
                    video_id:'',
                    videolist:[],
                    coverlist:[],
                    videoactive:'',
                    coveractive:'',
                    videonum:0,
                    covernum:0,
                    input:[{
                        value:'title1',
                        nametitle:'',
                    }],
                }]
            }
        },
        tabdelete(e,v){
            //删除创意
            var u = v-1;
           if(e ==0){
                var n = Object.keys(this.originshowsnum);
                if(this.originshowsnum[n[u]] ==true){
                    this.originshow = true;
                }else{
                    this.originshow = false;
                }
           }
           var nsn = Object.keys(this.originnum);
          this.originnum[nsn[u]] = this.originnum[nsn[u]] - 1;
           this.tablist.splice(e, 1)
        },
        onoriginality(v){
            if(this.tablist.length ==9){
                this.tabtrue = true;
            }else{
                this.tabtrue = false;
            }
            var u = v-1;
            var nsn = Object.keys(this.originnum);
            this.originnum[nsn[u]] += 1;
            //自定义添加
            this.tablist.push(this.tablist.length+1);
        },
        ontab(e){
            //添加创意
            this.tabactive = e;
        },
        onvideo(e){
            // 素材库
            var sub = this.customactive-1;
            // 根据视频宽高条件筛选
            var viderparems = "";
            // if(sub ==0){
            //     viderparems = {"filtering":{width:140,height:250}}
            // }else{
            //     viderparems = {"filtering":{width:250,height:140}}
            // }
            
            ajaxrequest("1657869217074189", VIDEOURL,viderparems).then((res) => {
                var videolist=res.data;
                // console.log(videolist);
                if(videolist.code=="SUCCESS"){
                    this.paneslist[sub].content.addpanel[e].videolist = videolist.data.list;
                    this.paneslist[sub].content.addpanel[e].videoshow = true;
                }else{
                    this.$message.error(videolist.message,3);
                }
            })
            // this.paneslist[sub].content.addpanel[e].videoshow = true;
        },
        metavideo(e){
            //程序化点击素材库
            var sub = this.progractive -1;
            var viderparems = ""; 
            ajaxrequest("1657869217074189", VIDEOURL,viderparems).then((res) => {
                var videolist=res.data;
                // console.log(videolist);
                if(videolist.code=="SUCCESS"){
                    this.customlist[sub].content.addpanel[e].videolist = videolist.data.list;
                    this.customlist[sub].content.addpanel[e].videoshow = true;
                }else{
                    this.$message.error(videolist.message,3);
                }
            })
        },
        handlevideo(e){
            // 素材库取消
            var sub = this.customactive-1;
            this.paneslist[sub].content.addpanel[e].videoshow = false;
        },
        handlevideos(e){
            // 程序化素材库取消
            var sub =this.progractive -1;
            this.customlist[sub].content.addpanel[e].videoshow = false; 
        },
        sourceserach(){
            //视频关键词搜索
        },
        onallsource(){
            // 全部来源
        },
        onvideoactive(i,e){
            // 选择视频
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].videoactive == e){
                this.paneslist[sub].content.addpanel[i].videoactive = '';
                this.paneslist[sub].content.addpanel[i].videonum =this.paneslist[sub].content.addpanel[i].videonum -1;
            }else{
                this.paneslist[sub].content.addpanel[i].videoactive = e;
                this.paneslist[sub].content.addpanel[i].videonum =1;
            }
        },
        onvideoactives(i,e){
            // 程序化选择视频
            var sub = this.progractive-1;
            if(this.customlist[sub].content.addpanel[i].videoactive == e){
                this.customlist[sub].content.addpanel[i].videoactive = '';
                this.customlist[sub].content.addpanel[i].videonum =this.customlist[sub].content.addpanel[i].videonum -1;
            }else{
                this.customlist[sub].content.addpanel[i].videoactive = e;
                this.customlist[sub].content.addpanel[i].videonum =1;
            }
        },
        oncoveractive(i,e){
            //选择封面图
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].coveractive == e){
                this.paneslist[sub].content.addpanel[i].coveractive = '';
                this.paneslist[sub].content.addpanel[i].covernum =this.paneslist[sub].content.addpanel[i].covernum -1;
            }else{
                this.paneslist[sub].content.addpanel[i].coveractive = e;
                this.paneslist[sub].content.addpanel[i].covernum =1;
            }
        },
        oncoveractives(i,e){
            //程序化选择视频
            var sub = this.progractive-1;
            if(this.customlist[sub].content.addpanel[i].coveractive == e){
                this.customlist[sub].content.addpanel[i].coveractive = '';
                this.customlist[sub].content.addpanel[i].covernum =this.customlist[sub].content.addpanel[i].covernum -1;
            }else{
                this.customlist[sub].content.addpanel[i].coveractive = e;
                this.customlist[sub].content.addpanel[i].covernum =1;
            }
        },
        oncoveractiveGroup(i,e,n){
            // 组图选择封面图
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].group[n].activeimg == e){
                this.paneslist[sub].content.addpanel[i].group[n].activeimg = '';
                this.paneslist[sub].content.addpanel[i].group[n].nums =this.paneslist[sub].content.addpanel[i].group[n].nums -1;
            }else{
                this.paneslist[sub].content.addpanel[i].group[n].activeimg = e;
                this.paneslist[sub].content.addpanel[i].group[n].nums =1;
            }
        },
        customRequest (data) {
            // 上传
            var i = data.data.index;//创意下标
            var sub = parseInt(data.data.sub)-1;//素材下标
            var uptype = data.data.uptype;//上传的类型
            // 竖版视频
            if(sub ==1){
                // 竖版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 100;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤100M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else if(sub ==2){
                // 横版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1000;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1000M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else{
                // 图片上传
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }
            const formData = new FormData()
            formData.append('file', data.file)
            formData.append('account_id', '1657869217074189')//随便写一个示例
           if(uptype ==1){
                // 视频上传
                ajaxfile(UPLOADVIDEO,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        this.paneslist[sub].content.addpanel[i].videoUrl = result.data.video_url;
                        this.paneslist[sub].content.addpanel[i].video_id = result.data.video_id;
                    }
                });
            }else{
                 // 图片上传
                 ajaxfile(UPLOADCOVER,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        if(sub ==3){
                            var n = data.data.group;
                            this.paneslist[sub].content.addpanel[i].group[n].img = result.data.url;
                            this.paneslist[sub].content.addpanel[i].group[n].image_id = result.data.id;
                        }else{
                            this.paneslist[sub].content.addpanel[i].imageUrl = result.data.url;
                            this.paneslist[sub].content.addpanel[i].image_id = result.data.id;
                        }
                    }
                });
            }
        },
        paogrRequest(data){
            // 程序化上传
             // 上传
             var i = data.data.index;//创意下标
             var sub = parseInt(data.data.sub)-1;//素材下标
             var uptype = data.data.uptype;//上传的类型

             // 竖版视频
             if(sub ==1){
                 // 竖版视频
                 if(uptype ==1){
                     const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                     if (!isJpgOrPng) {
                         this.$message.error('上传格式有误!');
                         return;
                     }
                     const isLt2M = data.file.size / 1024 / 1024 < 100;
                     if (!isLt2M) {
                       this.$message.error('超出上传大小≤100M');
                       return;
                     }
                 }
                 //封面图
                 if(uptype ==2){
                     const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                     if (!isJpgOrPng) {
                         this.$message.error('上传格式有误!');
                         return;
                     }
                     const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                     if (!isLt2M) {
                       this.$message.error('超出上传大小≤1.5M');
                       return;
                     }
                 }
             }else if(sub ==2){
                 // 横版视频
                 if(uptype ==1){
                     const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                     if (!isJpgOrPng) {
                         this.$message.error('上传格式有误!');
                         return;
                     }
                     const isLt2M = data.file.size / 1024 / 1024 < 1000;
                     if (!isLt2M) {
                       this.$message.error('超出上传大小≤1000M');
                       return;
                     }
                 }
                 //封面图
                 if(uptype ==2){
                     const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                     if (!isJpgOrPng) {
                         this.$message.error('上传格式有误!');
                         return;
                     }
                     const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                     if (!isLt2M) {
                       this.$message.error('超出上传大小≤1.5M');
                       return;
                     }
                 }
             }else{
                 // 图片上传
                 if(uptype ==2){
                     const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                     if (!isJpgOrPng) {
                         this.$message.error('上传格式有误!');
                         return;
                     }
                     const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                     if (!isLt2M) {
                       this.$message.error('超出上传大小≤1.5M');
                       return;
                     }
                 }
             }
             const formData = new FormData()
             formData.append('file', data.file)
             formData.append('account_id', '1657869217074189')//随便写一个示例
            if(uptype ==1){
                 // 视频上传
                 ajaxfile(UPLOADVIDEO,formData).then((res) => {
                     var result=res.data;
                     if(result.code =='SUCCESS'){
                         this.customlist[sub].content.addpanel[i].videoUrl = result.data.video_url;
                         this.customlist[sub].content.addpanel[i].video_id = result.data.video_id;
                     }else{
                         this.$message.error(result.message,3);
                     }
                 });
             }else{
                  // 图片上传
                  ajaxfile(UPLOADCOVER,formData).then((res) => {
                     var result=res.data;
                     if(result.code =='SUCCESS'){
                        this.customlist[sub].content.addpanel[i].imageUrl = result.data.url;
                        this.customlist[sub].content.addpanel[i].image_id = result.data.id;
                     }else{
                        this.$message.error(result.message,3);
                     }
                 });
             }
        },
        modecustomRequest(data){
            var i = data.data.index;//创意下标
            var sub = parseInt(data.data.sub)-1;//素材下标
            var uptype = data.data.uptype;//上传的类型
             // 竖版视频
             if(sub ==1){
                // 竖版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 100;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤100M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else if(sub ==2){
                // 横版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1000;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1000M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else{
                // 图片上传
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }

            const formData = new FormData()
            formData.append('file', data.file)
            formData.append('account_id', '1657869217074189')//随便写一个示例
           if(uptype ==1){
                // 视频上传
                ajaxfile(UPLOADVIDEO,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        this.$message.error("上传成功",3);
                        this.paneslist[sub].content.addpanel[i].videoUrl = result.data.video_url;
                        this.paneslist[sub].content.addpanel[i].video_id = result.data.video_id;
                    }else{
                        this.$message.error(result.message,3);
                    }
                });
            }else{
                 // 图片上传
                 ajaxfile(UPLOADCOVER,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        this.$message.error("上传成功",3);
                        if(sub ==3){
                            var n = data.data.group;
                            this.paneslist[sub].content.addpanel[i].group[n].img = result.data.url;
                            this.paneslist[sub].content.addpanel[i].group[n].image_id = result.data.id;
                        }else{
                            this.paneslist[sub].content.addpanel[i].imageUrl = result.data.url;
                            this.paneslist[sub].content.addpanel[i].image_id = result.data.id;
                        }
                    }else{
                        this.$message.error(result.message,3);
                    }
                });
            }
        },
        modepaogrRequest(data){
            var i = data.data.index;//创意下标
            var sub = parseInt(data.data.sub)-1;//素材下标
            var uptype = data.data.uptype;//上传的类型
             // 竖版视频
             if(sub ==1){
                // 竖版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 100;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤100M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else if(sub ==2){
                // 横版视频
                if(uptype ==1){
                    const isJpgOrPng = data.file.type === 'video/mp4' || data.file.type === 'video/mpeg' || data.file.type === 'video/3gp' || data.file.type === 'video/avi';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1000;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1000M');
                      return;
                    }
                }
                //封面图
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }else{
                // 图片上传
                if(uptype ==2){
                    const isJpgOrPng = data.file.type === 'image/jpg' || data.file.type === 'image/jpeg' || data.file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('上传格式有误!');
                        return;
                    }
                    const isLt2M = data.file.size / 1024 / 1024 < 1.5;
                    if (!isLt2M) {
                      this.$message.error('超出上传大小≤1.5M');
                      return;
                    }
                }
            }

            const formData = new FormData()
            formData.append('file', data.file)
            formData.append('account_id', '1657869217074189')//随便写一个示例
           if(uptype ==1){
                // 视频上传
                ajaxfile(UPLOADVIDEO,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        this.$message.error("上传成功",3);
                        this.customlist[sub].content.addpanel[i].videoUrl = result.data.video_url;
                        this.customlist[sub].content.addpanel[i].video_id = result.data.video_id;
                    }else{
                        this.$message.error(result.message,3);
                    }
                });
            }else{
                 // 图片上传
                 ajaxfile(UPLOADCOVER,formData).then((res) => {
                    var result=res.data;
                    if(result.code =='SUCCESS'){
                        this.$message.error("上传成功",3);
                        this.customlist[sub].content.addpanel[i].imageUrl = result.data.url;
                        this.customlist[sub].content.addpanel[i].image_id = result.data.id;
                    }else{
                        this.$message.error(result.message,3);
                    }
                });
            }
        },
        onuploadcardimg(data){
            //卡片上传图片
            const formData = new FormData()
            formData.append('file', data.file)
            formData.append('account_id', '1657869217074189')//随便写一个示例
            ajaxfile(UPLOADCOVER,formData).then((res) => {
                var result=res.data;
                if(result.code =='SUCCESS'){
                    this.$message.error("上传成功",3);
                    this.cardboximg = result.data.url;
                }else{
                    this.$message.error(result.message,3);
                }
            });
        },
        videook(i){
            // 视频弹窗确定
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].videonum ==0){
                this.$message.error('请先选择视频',3);
               return;//仍然阻止不了模态窗关闭
            }
            var videoid = this.paneslist[sub].content.addpanel[i].videoactive;
            var videoparems = {"filtering":{'video_ids':[videoid]}};
            ajaxrequest("1657869217074189", VIDEOURL,videoparems).then((res) => {
                var video=res.data;
                if(video.code =='SUCCESS'){
                    // this.videodata =videolist.data.list[0];
                    console.log(video);
                    this.paneslist[sub].content.addpanel[i].videoshow = false;
                    this.paneslist[sub].content.addpanel[i].videoUrl = video.data.list[0].url;
                    this.paneslist[sub].content.addpanel[i].video_id = video.data.list[0].id;
                }else{
                    this.$message.error(video.message,3);
                }
            })
        },
        videooks(i){
            // 程序化视频弹窗确定
            var sub = this.progractive-1;
            if(this.customlist[sub].content.addpanel[i].videonum ==0){
                this.$message.error('请先选择视频',3);
               return;//仍然阻止不了模态窗关闭
            }
            var videoid = this.customlist[sub].content.addpanel[i].videoactive;
            var videoparems = {"filtering":{'video_ids':[videoid]}};
            ajaxrequest("1657869217074189", VIDEOURL,videoparems).then((res) => {
                var video=res.data;
                if(video.code =='SUCCESS'){
                    // this.videodata =videolist.data.list[0];
                    this.customlist[sub].content.addpanel[i].videoshow = false;
                    this.customlist[sub].content.addpanel[i].videoUrl = video.data.list[0].url;
                    this.customlist[sub].content.addpanel[i].video_id = video.data.list[0].id;
                }else{
                    this.$message.error(video.message,3);
                }
            })
        },
        oncover(i){
            // 上传封面图
            var sub = this.customactive-1;
            var coverparems = "";
            if(sub ==0){
                coverparems = {filtering:{width:720,height:1280}}
            }else if(sub ==1){
                coverparems = {filtering:{width:1280,height:720}}
            }else if(sub ==2){
                coverparems = {filtering:{width:1280,height:720}}
            }else if(sub ==3){
                coverparems = {filtering:{width:456,height:300}}
            }else if(sub ==4){
                coverparems = {filtering:{width:456,height:300}}
            }else if(sub ==5){
                coverparems = {filtering:{width:720,height:1280}}
            }else{
                coverparems = {filtering:{width:720,height:1280}}
            }
            
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var coverlist=res.data;
                if(coverlist.code=="SUCCESS"){
                    this.paneslist[sub].content.addpanel[i].coverlist = coverlist.data.list;
                    this.paneslist[sub].content.addpanel[i].covershow = true;
                    
                }else{
                    this.$message.error(coverlist.message,3);
                }
            })
            // this.paneslist[sub].content.addpanel[i].covershow = true;
        },
        metaimage(i){
            // 程序化上传封面图
            var sub = this.progractive-1;
            var coverparems = "";
            if(sub ==0){
                coverparems = {filtering:{width:720,height:1280}}
            }else if(sub ==1){
                coverparems = {filtering:{width:1280,height:720}}
            }else if(sub ==2){
                coverparems = {filtering:{width:1280,height:720}}
            }else if(sub ==3){
                coverparems = {filtering:{width:456,height:300}}
            }else if(sub ==4){
                coverparems = {filtering:{width:456,height:300}}
            }else if(sub ==5){
                coverparems = {filtering:{width:720,height:1280}}
            }else{
                coverparems = {filtering:{width:720,height:1280}}
            }
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var coverlist=res.data;
                if(coverlist.code=="SUCCESS"){
                    this.customlist[sub].content.addpanel[i].coverlist = coverlist.data.list;
                    this.customlist[sub].content.addpanel[i].covershow = true;
                }else{
                    this.$message.error(coverlist.message,3);
                }
            })

        },
        oncoverGroup(i,n){
            // 组图
            var sub = this.customactive-1;
            console.log(this.paneslist[sub].content.addpanel[i].group[n].showis);
            var coverparems = {filtering:{width:456,height:300}}
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var coverlist=res.data;
                if(coverlist.code=="SUCCESS"){
                    this.paneslist[sub].content.addpanel[i].coverlist = coverlist.data.list;
                    this.paneslist[sub].content.addpanel[i].group[n].showis = true;
                }else{
                    this.$message.error(coverlist.message,3);
                }
            })
        },
        coverok(i){
            // 公共
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].covernum ==0){
                this.$message.error('请先选择封面图',3);
               return;//仍然阻止不了模态窗关闭
            }
            var coverid = this.paneslist[sub].content.addpanel[i].coveractive;
            var coverparems = {"filtering":{'image_ids':[coverid]}};
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var cover=res.data;
                if(cover.code =='SUCCESS'){
                    this.paneslist[sub].content.addpanel[i].covershow = false;
                    this.paneslist[sub].content.addpanel[i].imageUrl = cover.data.list[0].url;
                    this.paneslist[sub].content.addpanel[i].image_id = cover.data.list[0].id;
                }else{
                    this.$message.error(cover.message,3);
                }
            })
        },
        coveroks(i){
            // 程序化封面确定
            var sub = this.progractive-1;
            if(this.customlist[sub].content.addpanel[i].covernum ==0){
                this.$message.error('请先选择封面图',3);
               return;//仍然阻止不了模态窗关闭
            }
            var coverid = this.customlist[sub].content.addpanel[i].coveractive;
            var coverparems = {"filtering":{'image_ids':[coverid]}};
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var cover=res.data;
                if(cover.code =='SUCCESS'){
                    this.customlist[sub].content.addpanel[i].covershow = false;
                    this.customlist[sub].content.addpanel[i].imageUrl = cover.data.list[0].url;
                    this.customlist[sub].content.addpanel[i].image_id = cover.data.list[0].id;
                }else{
                    this.$message.error(cover.message,3);
                }
            })
        },
        coverokGroup(i,n){
            // 组图
            var sub = this.customactive-1;
            if(this.paneslist[sub].content.addpanel[i].group[n].nums ==0){
                this.$message.error('请先选择封面图',3);
               return;//仍然阻止不了模态窗关闭
            }
            var coverid = this.paneslist[sub].content.addpanel[i].group[n].activeimg;
            var coverparems = {"filtering":{'image_ids':[coverid]}};
            ajaxrequest("1657869217074189", IMGLIST,coverparems).then((res) => {
                var cover=res.data;
                if(cover.code =='SUCCESS'){
                    this.paneslist[sub].content.addpanel[i].group[n].showis = false;
                    this.paneslist[sub].content.addpanel[i].group[n].activeimg = cover.data.list[0].url;
                    this.paneslist[sub].content.addpanel[i].group[n].image_id = cover.data.list[0].id;
                }else{
                    this.$message.error(cover.message,3);
                }
            })
        },
        onhandlecover(i){
            //动态词包
            var sub = this.customactive -1;
            this.paneslist[sub].content.addpanel[i].dynamicmore = false;
        },
        handlecover(i){
            //公共
            var sub = this.customactive-1;
            this.paneslist[sub].content.addpanel[i].covershow = false;
        },

        handlecovers(i){
            var sub = this.progractive-1;
            this.customlist[sub].content.addpanel[i].covershow = false;
        },
        handlecoverGroup(i,n){
            // 组图
            var sub = this.customactive-1;
            this.paneslist[sub].content.addpanel[i].group[n].showis = false;
        },
        ontitle(e,v){
            var sub = this.customactive-1;
            // 标题
           this.paneslist[sub].content.addpanel[e].nametitle = v.target.value;
        },
        ontitles(e,v){
            // 程序化标题
            // if(v.target.value ==""){
            //     this.
            // }
            this.input[e].nametitle = v.target.value;
        },
        onaddtitle(){
            // 程序化添加标题
            if(this.input.length > 9){
                this.addtitledis = true;
                return;
            }

            var num = this.inputnum +1; 
            this.input.push({
                value:`title${num}`,
                nametitle:'',
                dynamicmores:false,
                dynamiclists:[],
                words_ids:[],
            })

            this.inputnum = num;
        },
        ondeltitle(e){
            // 程序化删除标题
            this.input.splice(e, 1)
        },
        ondynamic(e,v,ids){
            // 动态词包
            var sub = this.customactive-1;
            this.paneslist[sub].content.addpanel[v].dynamicmore = false;
            var name = this.paneslist[sub].content.addpanel[v].nametitle;
            if(this.paneslist[sub].content.addpanel[v].creative_word_ids.length < 2){
                this.paneslist[sub].content.addpanel[v].nametitle =name+e;

                this.paneslist[sub].content.addpanel[v].creative_word_ids.push(ids);
            }else{
                this.$message.error("最多插入两个词包",3);
            }
        },
        ondynamics(e,v){
            // 程序化动态词包
            this.input[v].dynamicmore = false;
            var name = this.input[v].nametitle;
            if(this.input[v].words_ids.length <2){
                this.input[v].nametitle = name+e;
                this.input[v].words_ids.push(1);
            }else{
                this.$message.error('最多插入两个词包',3);
            }
        },
        handleCancels(v){
            // 程序化取消动态词
            this.input[v].dynamicmores = false;
        },
        oncardimg(){
            //素材库
            this.cardbox = true;
        },
        ondynamicmore(i){
            var sub = this.customactive-1;
            //更多词包
            ajaxrequest("1657869217074189", DYNAMIC,"").then((res) => {
                var dynamic=res.data;
                if(dynamic.code == 'SUCCESS'){
                    this.paneslist[sub].content.addpanel[i].dynamicmore = true;
                    this.paneslist[sub].content.addpanel[i].dynamiclist = dynamic.data.creative_word;
                }else{
                    this.$message.error(dynamic.message,3);
                }
                
            })
        },
        ondynamicmores(n){
            // 动态词包
            ajaxrequest("1657869217074189", DYNAMIC,"").then((res) => {
                var dynamic=res.data;
                if(dynamic.code == 'SUCCESS'){
                    this.input[n].dynamicmores = true;
                    this.input[n].dynamiclists = dynamic.data.creative_word;
                }else{
                    this.$message.error(dynamic.message,3);
                }
                
            })
        },
        dynamicok(){
            this.dynamicmore = false;
        },
        dynamicCancel(){
            this.dynamicmore = false;
        },
        cardCancel(){
            //取消卡片主图
            this.cardbox = false;
        },
        cardOk(){
            //确定卡片主图
            this.cardbox =false;
        },
        oncardtitle(e){
            //卡片标题
            this.cardtitle = e;
        },
        onpoint(){
            //推广卖点
            if(this.inputlist.length >=10){
                this.btnpoint = true;
                return;
            }else{
                this.btnpoint = false;
            }

            var num = this.pointsnum +1;
            this.inputlist.push({
                valuename:`product_selling_points${num}`,
                value:'',
            });
            this.pointsnum = num;
        },
        onpoints(i,e){
            // 推广卖点获取input内容
            this.inputlist[i].value = e.target.value;
        },
        onsystempoint(){
            // 系统推荐卖点
            this.systemshow = true;
        },
        systemok(){
            this.systemshow = false;
        },
        systemCancel(){
            this.systemshow = false;
        },
        ondelinput(e){
            // console.log(this.inputlist);
            //删除推广卖点
            this.inputlist.splice(e, 1)
        },
        onactiontext(e){
            // 行动号召
            this.actiontext = e.target.value;
        },
        onbrandhone(e){
            // 品牌主页
            this.brandhome = e.target.value;
        },
        oncomment(e){
            //广告评论
            this.comments = e.target.value;
        },
        ontoshow(e){
            //创意展现
            this.toshow = e.target.value;
        },
        onlabel(e){
            //标签(按钮添加)
            if(this.labellist.indexOf(e)){
                this.labellist.push(e);
            }
        },
        dellabel(v){
            //删除标签
            this.labellist.splice(v,1)
        },
        handleAddlabel(e){
            //标签(回车添加)
            if(this.labellist.indexOf(e.target.value)){
                this.labellist.push(e.target.value);
            }
        },
        choiceorign(){
            // 选择程序化创意包
            ajaxrequest("1657869217074189", PROGRAM,"").then((res) => {
                var result=res.data;
                if(result.code =="SUCCESS"){
                    this.choiceorignbox = true;
                    this.choicelist =result.data.list;
                }
            })


            
        },
        onchoice(){
            // 程序化创意包模式搜索

        },
        cancel(){
            // 取消
            this.$router.push('/promotion/advering/originality')
        },
        savebtn(){
            // 保存
            this.form.validateFieldsAndScroll((err, values) => {
                this.logging = true;
                console.log(err);
                //广告主ID
                values['advertiser_id'] = "1657869217074189";
                // 计划ID
                values['ad_id'] = this.id;
                // 位置
                if(values['a']=='inventory_type'){
                    if(this.mediaboxlist.length ==0){
                        this.$message.error("请选择媒体指定位置", 3);
                        return;
                    }
                    values['inventory_type'] = this.mediaboxlist;
                }else if(values['a'] =='scene_inventory'){
                    if(this.cenelistbox.length ==0){
                        this.$message.error("请选择场景指定位置", 3);
                        return;
                    }
                    values['scene_inventory'] = this.cenelistbox[0].value;
                }else{
                    values['smart_inventory'] = 1;
                }

                //程序化
                if(values['creative_material_mode'] =="STATIC_ASSEMBLE"){
                    values['creative_material_mode'] = 'STATIC_ASSEMBLE';
                    let creatives = [];
                    this.paneslist.forEach((item)=>{
                        if(item.content.num !== 0){
                            item.content.addpanel.forEach((i)=>{
                                creatives.push({
                                    image_mode:item.value,
                                    title:i.nametitle,
                                    creative_word_ids:i.creative_word_ids,
                                    image_id:i.image_id,
                                    video_id:i.video_id
                                });
                            })
                        }
                        values['creatives'] = creatives.toString();
                    })
                    let title_list = [];
                    this.input.forEach((item)=>{
                        title_list.push({
                            title:item.nametitle,
                            creative_word_ids:this.words_ids
                        });
                    });
                    values['title_list'] = title_list.toString();
                }else{
                    // 自定义
                    this.$delete(values,'creative_material_mode');//自定义无需定义 
                    let creatives = [];
                    // let img = '';

                    if(this.num.length <=0){
                        this.$message.error('请上传创意内容');
                        return;
                    }
                    
                    this.paneslist.forEach((item,index)=>{
                        if(item.content.num !== 0){
                            item.content.addpanel.forEach((i)=>{
                                if(index ==3){
                                    creatives.push({
                                        image_mode:item.value,
                                        title:i.nametitle,
                                        creative_word_ids:i.creative_word_ids,
                                        image_ids:[i.group[0].image_id,i.group[1].image_id,i.group[2].image_id],
                                        video_id:i.video_id
                                    });
                                }else{
                                    creatives.push({
                                        image_mode:item.value,
                                        title:i.nametitle,
                                        creative_word_ids:i.creative_word_ids,
                                        image_id:i.image_id,
                                        video_id:i.video_id
                                    });
                                }
                              
                            })
                        }
                         // 创意包
                        values['creatives'] = creatives;
                    })
                }
               
                // 同步封面标题
                if(values['derive_poster_cid'] ==true){
                    values['derive_poster_cid'] = 1;
                }else{
                    values['derive_poster_cid'] = 0;
                }

                //品牌主页
                if(values['is_feed_and_fav_see'] ==true){
                    values['is_feed_and_fav_see'] =1;
                }else{
                    values['is_feed_and_fav_see'] = 0;
                }

                //创意标签
                if(this.labellist.length <=0){
                    this.$message.error("请输入创意标签",3);
                    return;
                }
                values['ad_keywords'] = this.labellist;
                //卡片图片
                // values['product_image_id'] = this.cardboximg;

                //推广卖点
                // let product_selling_points=[];
                // this.inputlist.forEach((item) =>{
                //     product_selling_points.push({
                //         value:item.value,
                //     })
                // });
                // values['product_selling_points'] = product_selling_points.toString();
                //不开启抖音用户
                if(values['ies_core_user_id'] =='0'){
                    this.$delete(values,'ies_core_user_id');
                }
                if(values['third_industry_id'] !=undefined){
                    values['third_industry_id'] = values['third_industry_id'][2];
                }else{
                    this.$message.error("请选择创意分类");
                    return;
                }
                // console.log(values);
                // console.log(ADDORIGIN);
                // console.log(ajaxnoparams);
                ajaxnoparams("1657869217074189", ADDORIGIN,values).then((res) => {
                    var result=res.data;
                    this.logging = false;
                    // console.log(result);
                    if(result.code =="SUCCESS"){
                        this.$router.push('/promotion/advering/originality');
                    }else{
                        this.$message.error(result.message,3);
                    }
                })

            })
        },
        imgurl(name) {
            return require("@/assets/img/" + name);
        },
    },
    computed: {
        ...mapGetters('account', ['user']),
        rowmedialist(){
          return {
            onChange: (selectedRowKeys, selectedRows) => {
                this.mediaboxlist = selectedRows
              console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
            },
          };
        },
        rowscenelist(){
            return {
                type:'radio',
                selections:true,
                onChange: (selectedRowKeys, selectedRows) => {
                    this.cenelistbox = selectedRows;
                        // this.selectedRows = selectedRows;
                    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
                },
            };
        },
        rowsystempoint(){
            return {
                hideDefaultSelections: true,
                onChange: (selectedRowKeys, selectedRows) => {
                    this.rowsystemlist = selectedRows;
                        // this.selectedRows = selectedRows;
                    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
                },
            };
        },
    }
}